<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>紫色鹭</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div id="header_01_html">
    <iframe id="header_01" src="head_01.html" frameborder="0"></iframe>
</div>
<div class="login">
    <img src="../img/login_01.png" alt="" class="login_bg">
    <div class="container" style="position: initial;"><img src="../img/logo.png" alt="" class="logo" onclick="location.href = 'index.html'"></div>
    <div class="login_box">
        <div class="title">欢迎登录</div>
        <div class="box">
            <ul>
                <li class="border">
                    <i class="icon_login"></i>
                    <input type="text" placeholder="请输入用户名" id="username">
                </li>
                <li class="border">
                    <i class="icon_password"></i>
                    <input type="password" placeholder="请输入登录密码" id="password">
                </li>
                <li class="clearfix">
                    <span class="fl"><i class="icon_checkbox"></i>记住密码</span>
                </li>
                <li>
                    <div class="submit">登录</div>
                </li>
                <li><div class="signBtn">立即注册</div></li>
                <li class="get-password"><a target="_blank"  href="forget_password.html">忘记密码？</a></li>
            </ul>
        </div>
    </div>
</div>
</body>
<script src="../js/config.js"></script>
<script>
    var list = ["register_01", "register_02", "register_03","set_pswd_succ"];

    $("#username").val(localStorage.getItem("username"));
    if(localStorage.getItem("rember")){
        $(".icon_checkbox").addClass("active");
        var password = localStorage.getItem("password");
        $("#password").val(password);
    }
    $("body").on('keyup',function(event){
        event=document.all?window.event:event;
        if((event.keyCode || event.which)==13){
            $(".submit").click();
        }
    });
    $(".submit").click(function () {
        var rember = $(".icon_checkbox").hasClass("active");
        var username = $("#username").val();
        var password = $("#password").val();
        if (!username) {
            layer.msg("请输入用户名");
            return
        }
        if (!password) {
            layer.msg("请输入密码");
            return
        }
        get_ajax("/web/auth/login", {username: username, password: password}, function (data) {
            var storageData = {username: username,Token:data};
            if (rember) {
                storageData["rember"] = true;
                storageData["password"] = password;
            }
            setStorage(storageData);
            if (list.indexOf(pageName(document.referrer))) {
                location.href = "index.html";
            } else {
                history.go(-1)
            }
        })
    })

    function pageName(a) {
        var b = a.split("/");
        var c = b.slice(b.length - 1, b.length).toString(String).split(".").slice(0, 1)[0];
        return c;
    }
</script>
</html>